package com.example.switch_text.utils;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * 统一API响应结果封装
 */
@ApiModel( description = "返回对象内容")
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class ResponseResult<T> {
    @ApiModelProperty(value = "编码code", required = true)
    private String responseCode;
    @ApiModelProperty(value = "消息内容", required = true)
    private String responseMessage;
    @ApiModelProperty("响应结果")
    private T data;
    @ApiModelProperty("时间")
    private String updateTime;


    public ResponseResult setResponseCode(ResultCode resultCode) {
        this.responseCode = resultCode.responseCode();
        return this;
    }

    public String getResponseCode() {
        return responseCode;
    }

    public ResponseResult setResponseCode(String resultCode) {
        this.responseCode = resultCode;
        return this;
    }

    public String getResponseMessage() {
        return responseMessage;
    }

    public ResponseResult setResponseMessage(String responseMessage) {
        this.responseMessage = responseMessage;
        return this;
    }

    public T getData() {
        return data;
    }

    public ResponseResult setData(T data) {
        this.data = data;
        return this;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public ResponseResult setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
        return this;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
